<template>
    <div>
        <el-row>
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
                <el-form-item label="操作人员">
                    <el-input v-model="formInline.operateMan" placeholder="操作人员"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">查询</el-button>
                </el-form-item>
            </el-form>
        </el-row>
        <el-row>
            <el-table
                    :data="tableData"
                    style="width: 100%">
                <el-table-column
                        prop="id"
                        label="#">
                </el-table-column>
                <el-table-column
                        prop="memberName"
                        label="会员名称">
                </el-table-column>
                <el-table-column prop="createTime" label="创建记录时间">
                    <template slot-scope="scope">
                        <i class="el-icon-time"></i>
                        <span style="margin-left: 10px">{{(scope.row.createTime.split(` `)[0])}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="changeType" label="积分变化">
                    <template slot-scope="scope">{{scope.row.changeType ===1 ?'增加':'减少'}}</template>
                </el-table-column>
                <el-table-column
                        prop="changeCount"
                        label="积分改变数量">
                </el-table-column>
                <el-table-column
                        prop="operateMan"
                        label="操作人员">
                </el-table-column>
                <el-table-column
                        prop="operateNote"
                        label="操作备注">
                </el-table-column>
                <el-table-column prop="addtime" label="添加时间">
                    <template slot-scope="scope">
                        <i class="el-icon-time"></i>
                        <span style="margin-left: 10px">{{(scope.row.addtime.split(` `)[0])}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="sourceType" label="积分来源" >
                    <template slot-scope="scope">
                        <span v-if="scope.row.sourceType === 0"><el-button size="mini"
                                                                           type="info">自驾服务消费金额</el-button></span>
                        <span v-if="scope.row.sourceType === 1"><el-button size="mini" type="primary">参与官方活动</el-button></span>
                        <span v-if="scope.row.sourceType === 2"><el-button size="mini" type="warning">官网个人消费</el-button></span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="180">
                    <template slot-scope="scope">
                        <el-button
                                size="mini"
                                type="danger"
                                @click="handleDelete(scope.$index, scope.row)">删除
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-row>
        <el-row>
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[2,3,5,10]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </el-row>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                tableData: [],
                sex: '',
                level: '',
                status: '',
                currentPage: 1,
                total: 100,
                formInline: {operateMan: ``},
                pageSize: 5,
                dialogVisible: false,
            }
        },
        // 初始化数据  mounted()
        created: function () {
            this.loadData();
        },
        methods: {
            //封装数据请求
            loadData() {
                let _this = this;
                this.$http.post("/ms/integrationHistory/queryAll?pageNo=" + this.currentPage + "&pageSize=" + this.pageSize + "", this.formInline)
                    .then((response) => {
                        let list = response.data.t.list;
                        console.log(list);
                        _this.tableData = list
                        _this.total = response.data.t.total;
                    })
            },
            //处理编辑
            handleEdit(index, row) {
                this.clearPopForm();
                this.dialogVisible = true;
                this.form = JSON.parse(JSON.stringify(row))

            },
            //处理删除
            handleDelete(index, row) {
                this.$http.delete("/ms/integrationHistory/deleteById/" + row.id + "").then((resp) => {
                    if (Number(resp.data.resultCode) === 2000) {
                        this.$message({
                            message: '删除成功',
                            type: 'success'
                        })
                        this.currentPage = 1;
                        this.loadData();
                    }
                    if (Number(resp.data.resultCode) === 5000) {
                        this.$message({
                            message: '删除',
                            type: 'error'
                        })
                    }
                })
            },
            //分页 每页数量变化时处理
            handleSizeChange(val) {
                this.pageSize = val;
                this.currentPage = 1;
                this.loadData();
            },
            //分页 第几页变化时处理
            handleCurrentChange(val) {
                this.currentPage = val;
                this.loadData();
            },
            //点击查询方法
            onSubmit() {
                this.currentPage = 1;
                this.loadData();
                this.formInline.operateMan = ''
            }
        }
    }
</script>

<style scoped>

</style>